package it.unibz.inf.cn;


public class Updater {

	private Client client = null;
	long timestamp = 0;
	
	public Updater(Client c){
		client = c;
	}
	
	public void startUpdateing() throws Exception{
		timestamp = System.currentTimeMillis();
		startThread();
	}
	
	private void startThread(){
		Thread th = new Thread(new Runnable() {
			
			@Override
			public void run() {
				while(true){
					try {
						long aux = System.currentTimeMillis();
						if(aux - 60000 > timestamp){
							client.updateTweets();
							timestamp = aux;
						}						
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		});
		th.start();
	}
}
